﻿Public Class AnimationScreenflash
    Inherits ObjektAnimation
    Const FrameMax As Integer = 51
    Public Sub New(ByVal Musikspielen As Boolean)
        MyBase.New(Musikspielen, ObjektSpielfeld.TopLayer)

        'Wir fügen die Handler hinzu
        AddHandler Hauptmenü.MainMenü.MalPanel.MouseDown, AddressOf MouseDown
        AddHandler Hauptmenü.MainMenü.KeyDown, AddressOf KeyDown
    End Sub
    Public Overrides Function Malen(ByVal intColor As System.Drawing.Color, Optional ByVal Zoomfaktor As Single = 1.0) As Boolean
        If Frame <= 25 Then
            Grafikengine.fillRect(New Rectangle(0, 0, Hauptmenü.MainMenü.MalPanel.Width, Hauptmenü.MainMenü.MalPanel.Height), Color.FromArgb(Frame * 10, 255, 255, 255))
        ElseIf Frame > 25 And Frame <= 26 Then
            Grafikengine.fillRect(New Rectangle(0, 0, Hauptmenü.MainMenü.MalPanel.Width, Hauptmenü.MainMenü.MalPanel.Height), Color.FromArgb(255, 255, 255, 255))
        Else

            Dim Alpha As Integer = 250 - (Frame - 26) * 10
            If Alpha < 0 Then Alpha = 0
            Grafikengine.fillRect(New Rectangle(0, 0, Hauptmenü.MainMenü.MalPanel.Width, Hauptmenü.MainMenü.MalPanel.Height), Color.FromArgb(Alpha, 255, 255, 255))
        End If
        If FrameMax >= Frame Then
            Frame += 1
            Return True
        Else
            Return False
        End If
    End Function
    Public Sub MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Select Case e.Button
            Case MouseButtons.Right
                Frame += FrameMax
        End Select
    End Sub
    Private Sub KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        Select Case e.KeyCode
            Case My.Settings.Bestätigen
                Frame += FrameMax
            Case My.Settings.Abrechen
                Frame += FrameMax
        End Select
    End Sub
    Public Overrides Sub RemoveHandles()
        MyBase.RemoveHandles()
        RemoveHandler Hauptmenü.MainMenü.MalPanel.MouseDown, AddressOf MouseDown
        RemoveHandler Hauptmenü.MainMenü.KeyDown, AddressOf KeyDown
    End Sub
End Class
